<?php

namespace Analysis\Controller;

class SettController extends CommController
{
    public function index()
    {
        $preftype = M("preftype");

        $data = commpage($preftype, "pre_status < 3", "pre_time desc", 12);
        $this->assign("data", $data);
        $this->display();
    }

    public function indexedit($pid)
    {
        $preftype = M("preftype");

        $data = $preftype->find($pid);
        $this->assign("data", $data);
        $this->display();
    }

    public function type()
    {
        $saletype = M("saletype");

        $data = commpage($saletype, null, null, 12);
        $this->assign("data", $data);
        $this->display();
    }

    public function typeadd()
    {
        $preftype = M("preftype");
        $this->assign("sal", $preftype->where("pre_status=1")->select());
        $this->display();
    }

    public function typeedit($sit)
    {
        $saletype = M("saletype");
        $preftype = M("preftype");

        $data = $saletype->find($sit);
        $this->assign("data", $data);
        //
        $this->assign("sal", $preftype->where("pre_status=1")->select());
        $this->display();
    }
    
    public function rules()
    {
        $platrule=M("platrule");
        
        $data = commpage($platrule, null, null, 12);
        $this->assign("data", $data);
        $this->display();
    }
    
    public function rulesadd()
    {
        $saletype = M("saletype");
        $this->assign("type", $saletype->select());
        $this->display();
    }
    
    public function rulesedit($rod)
    {
        $platrule=M("platrule");
        $saletype = M("saletype");
        $this->assign("type", $saletype->select());
        
        $data=$platrule->find($rod);
        $this->assign("data", $data);
        $this->display();
    }

    public function mana()
    {
        $this->controlAct();
        $groupuser = M("groupuser");

        $data = commpage($groupuser, null, null, 12);
        $this->assign("data", $data);
        $this->display();
    }

    public function manaadd()
    {
        $this->controlAct();
        $this->display();
    }

    public function manaedit($god)
    {
        $this->controlAct();
        $groupuser = M("groupuser");

        $data = $groupuser->find($god);
        $this->assign("data", $data);
        $this->display();
    }

    public function applylog()
    {
        $smscenter = M("smscenter");

        $data = commpage($smscenter, null, "smc_id desc", 12);
        $this->assign("data", $data);
        $this->display();
    }
    
    public function dist()
    {
        $dist = M("dist");

        $data = commpage($dist, null, "di_time desc", 12);
        $this->assign("data", $data);
        $this->display();
    }

    //common
    private function controlAct()
    {
        $groupuser = M("groupuser");

        $data = $groupuser->find(session("dataAnalsys"));
        if ($data["gro_type"] != 5) {
            $this->error("没有管理权限");
        }
    }
}
